# _*_ coding : utf-8 _*_
# @Time : 2024-06-11 11:09
# @Author : haowen
# @File : getoneshares
# @Project : pyserver
from pyecharts.charts import Line
from pyecharts import options as opts
import akshare as ak


def createChars(startData, sharesCode):
    # 获取股票数据
    start_date = startData
    symbol = sharesCode
    stock_zh_a_hist_df = ak.stock_zh_a_hist(
        symbol=symbol,
        period="daily",
        # start_date=start_date,
        adjust="hfq"
    )

    x_data = stock_zh_a_hist_df['日期'].tolist()
    y_data = stock_zh_a_hist_df['收盘'].tolist()

    # 创建折线图对象
    line = Line()
    line.add_xaxis(x_data)
    line.add_yaxis(symbol, y_data)

    line.set_global_opts(
        title_opts=opts.TitleOpts(title=f"{symbol} 股票走势图"),
        xaxis_opts=opts.AxisOpts(type_="category"),
        yaxis_opts=opts.AxisOpts(type_="value"),
    )

    line.render("../public/zoushi.html")


# createChars("20200101", "000004")
